package com.wunu.smartlock1.activity;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import com.wunu.smartlock1.R;
import com.wunu.smartlock1.model.AuthorizedMemberVo;
import java.util.List;
import java.util.ArrayList;
import com.wunu.smartlock1.adapter.AuthorizedMemberAdapter;
import android.widget.ListView;
/**
 * Created by admin on 2018/4/21.
 */

public class AuthorizedLockActivity extends AppCompatActivity{

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.smartlock_activity_authorizedlock);

        List<AuthorizedMemberVo> list = getMemberList();
        //给button按钮绑定单击事件，设置完参数后跳转到首页

        AuthorizedMemberAdapter adapter = new AuthorizedMemberAdapter(AuthorizedLockActivity.this, R.layout.smartlock_activity_authorized_item, list);
        ListView listView = (ListView) findViewById(R.id.authorizedListView);
        listView.setAdapter(adapter);
    }
    public List<AuthorizedMemberVo> getMemberList(){
        List<AuthorizedMemberVo> list = new ArrayList<AuthorizedMemberVo>();
        for(int i=0;i<20;i++){
            AuthorizedMemberVo obj = new AuthorizedMemberVo();
            obj.setAuthorizedType("认证成员");
            obj.setUserContent("包括管理员、家庭成员、保姆、钟点工等");
            obj.setAuthorizedName("柳岸花明");
            obj.setAuthorizedPicUrl(R.mipmap.members);
            obj.setAuthorizedDescript("家庭成员");
            obj.setMemberType(0);
            obj.setMenberPicUrl(R.mipmap.members);
            obj.setUsedTimes((int)Math.random()%200);
            obj.setLeftTimes((int)Math.random()%100);
            list.add(obj);
        }
        AuthorizedMemberVo obj = new AuthorizedMemberVo();
        obj.setAuthorizedType("临时秘钥");
        obj.setUserContent("仅限管理员、家庭成员可授权");
        obj.setAuthorizedName("爱恨交戈");
        obj.setAuthorizedPicUrl(R.mipmap.members);
        obj.setAuthorizedDescript("已过期");
        obj.setMemberType(1);
        obj.setMenberPicUrl(R.mipmap.members);
        obj.setUsedTimes(100);
        obj.setLeftTimes(23);
        list.add(obj);
        return list;
    }
}
